/*
 * Copyright (c) 2006, 2023, webrx.cn All rights reserved.
 *
 */

package cn.webrx;

import java.util.Calendar;
import java.util.concurrent.TimeUnit;

/**
 * <p>Project: jse2303 - Ex1</p>
 * <p>Powered by webrx On 2023-07-27 09:03:35</p>
 * <p>描述：<p>
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Ex1 {
    public static void main(String[] args) {
        var ex = new Ex1();
        var t = new Thread(ex::worker);
        t.start();
    }

    void worker() {
        while (true) {
            //月末
            Calendar c = Calendar.getInstance();
            int m = c.get(Calendar.MONTH);
            c.set(c.get(Calendar.YEAR), m + 1, 1, 0, 0, 0);
            c.add(Calendar.HOUR_OF_DAY, -22);

            if (System.currentTimeMillis() == c.getTimeInMillis()) {
                System.out.printf("%tF %<tT %n", System.currentTimeMillis());
                try {
                    TimeUnit.SECONDS.sleep(1);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }

        }
    }
}
